//---------------------------------------------------------------------------- // File: C3DQuad.h // Class: C3DQuad -- Common Quad, plane. // Type: 3D Object // Author: Ken Anderson // Date: 4/10/2005 -- Redesigned as a Quad. // OS dependant: NA // Desc: A class designated to manage transformed or untransformed quads. // In otherwords, quads that are mapped into the 3d world or against // the screen using 2d coordinates. Quads maybe composed of a simple // set of triangles or a complex collection of triangles. // // Revisions // v1.1 -- Bug found in the method in vertices construction, would leave 3d // objects upside down rather than right side up. // // Required headers: // 1) C3DVertices.h -- A link to the vertices required to create the quads. // 2) C3DTextures.h -- A link to a texture to wrap around the quad. //---------------------------------------------------------------------------- #ifndef __C3DQUAD__ #define __C3DQUAD__ /////////////// // INCLUDES // /////////////// #include "C3DVertices.h" #include "C3DTextures.h" #include "C3DIndices.h" class C3DQuad { public: C3DQuad(); C3DQuad(const C3DQuad& quad); ~C3DQuad(); //Quad controllers. C3DERR Create(float fx=0.0f, float fy=0.0f, float fx2=0.0f, float fy2=0.0f, float fz=0.0f, bool bQuad2D=true, int nComplexity=1, Byte byAlphaStyle=0x00); C3DERR Render(float fsystime); //Quad Texture management. C3DERR SetTexture(string& sTexture); C3DERR SetTexture(CiMedia* pMedia); /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: ClearTexture // Date: 5/27/05 // Type: Common 3D Object. // Desc: Clears the texture and renders the quad as a shaded object. // Parameters: None // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void ClearTexture(){SDELETE(m_pTexture);} //Properties. inline FRect GetPositionCoords(){return m_frPosCoord;} inline FRect GetTextureCoords(){return m_frTexCoord;} inline DRect GetColorCoords(){return m_drColorCoord;} inline FRect GetNormalCoords(){return m_frNormalCoord;} inline float GetZCoord(){return m_fZ;} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: GetHeight // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Returns the height of the Quad. // Parameters: None // Return value: // float == Returns the height. ////////////////////////////////////////////////////////////////////////////////////////////////////// inline float GetHeight(){return ((m_frPosCoord.y2 > m_frPosCoord.y)?(m_frPosCoord.y2-m_frPosCoord.y):(m_frPosCoord.y-m_frPosCoord.y2));} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: GetWidth // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Returns the width of the Quad. // Parameters: None // Return value: // float == Returns the width. ////////////////////////////////////////////////////////////////////////////////////////////////////// inline float GetWidth(){return ((m_frPosCoord.x2 > m_frPosCoord.x)?(m_frPosCoord.x2-m_frPosCoord.x):(m_frPosCoord.x-m_frPosCoord.x2));} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetPositionCoords // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the position coordinates of the triangle box. // Parameters: // 1) FRect frCoords == A block of coordinates to set. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetPositionCoords(FRect frCoords){m_frPosCoord = frCoords;CVC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetPositionCoords -- OVERLOADED // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the position coordinates of the triangle box. // Parameters: // 1) float fx == First point on the x-axis. // 2) float fy == First point on the y-axis. // 3) float fx2 == Second point on the x-axis. // 4) float fy2 == Second point on the y-axis. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetPositionCoords(float fx, float fy, float fx2, float fy2){m_frPosCoord.x = fx;m_frPosCoord.y = fy;m_frPosCoord.x2 = fx2;m_frPosCoord.y2 = fy2;CVC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetTextureCoords // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the texture coordinates of the triangle box. // Parameters: // 1) FRect frCoords == A block of coordinates to set. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetTextureCoords(FRect frCoords){m_frTexCoord = frCoords;CTC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetTextureCoords -- OVERLOADED // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the texture coordinates of the triangle box. // Parameters: // 1) float fu == First point on the x-axis. // 2) float fv == First point on the y-axis. // 3) float fu2 == Second point on the x-axis. // 4) float fv2 == Second point on the y-axis. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetTextureCoords(float fu, float fv, float fu2, float fv2){m_frTexCoord.x = fu;m_frTexCoord.y = fv;m_frTexCoord.x2 = fu2;m_frTexCoord.y2 = fv2;CTC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetNormalCoords // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the normal coordinates of the triangle box. // Parameters: // 1) FRect frCoords == A block of coordinates to set. // Return value: None /////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetNormalCoords(FRect frCoords){m_frNormalCoord = frCoords;CNC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetNormalCoords -- OVERLOADED // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the normal coordinates of the triangle box. // Parameters: // 1) float fx == First point on the x-axis. // 2) float fy == First point on the y-axis. // 3) float fx2 == Second point on the x-axis. // 4) float fy2 == Second point on the y-axis. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetNormalCoords(float fx, float fy, float fx2, float fy2){m_frNormalCoord.x = fx;m_frNormalCoord.y = fy;m_frNormalCoord.x2 = fx2;m_frNormalCoord.y2 = fy2;CNC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetColorCoords // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the color for the four coordinates in the order of vertices in a clockwise order. // Parameters: // 1) FRect frCoords == A block of coordinates to set. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetColorCoords(DRect drCoords){m_drColorCoord = drCoords;CCC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetColorCoords -- OVERLOADED // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the color for the four coordinates. // Parameters: // 1) Dword dx == First triangle bottom left. // 2) Dword dx2 == Second triangle point top left. // 3) Dword dx3 == Third triangle point top right. // 4) Dword dx4 == Fourth triangle point bottom right. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetColorCoords(Dword dx, Dword dx2, Dword dx3, Dword dx4){m_drColorCoord.x = dx;m_drColorCoord.x2 = dx2;m_drColorCoord.x3 = dx3;m_drColorCoord.x4 = dx4;CCC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetZCoord // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the Z Coordinate of the Quad. // Parameters: // 1) float fz == A float value that contains the z-axis position of the quad. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetZCoord(float fz){m_fZ = fz;} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetHeight // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the height of the triangle box. // Parameters: // 1) float fHeight == The height of the triangle box. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetHeight(float fHeight){m_frPosCoord.y2 = m_frPosCoord.y + fHeight;CVC();} /////////////////////////////////////////////////////////////////////////////////////////////////////// // Name: SetWidth // Date: 4/10/2005 // Type: Common 3D Object. // Desc: Sets the width of the triangle box. // Parameters: // 1) float fHeight == The width of the triangle box. // Return value: None ////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SetWidth(float fWidth){m_frPosCoord.x2 = m_frPosCoord.x + fWidth;CVC();} private: //Update functions. bool CVC(); //Update Vertex Coordinates. bool CTC(); //Update Texture Coordinates. bool CCC(); //Update Color Coordinates. bool CNC(); //Update Normal Coordinates. FRect m_frPosCoord; //Box Coordinates FRect m_frTexCoord; //Texture Coordinates FRect m_frNormalCoord; //Normal Coordinates. DRect m_drColorCoord; //Color Coordinates //Location on the z-axis. float m_fZ; //Toggles whether the vertices should be updated //or created as new. bool m_bTransformed; Byte m_byAlphaStyle; //Complexity of the quad, number of boxes int m_nPrims; //Vertices C3DVertices* m_pfVerts; C3DTextures* m_pTexture; C3DIndices* m_pIndices; }; #endif